import { Message, MessageBox, Loading } from 'element-ui'

/** 成功的消息提醒 **/
export const Success =  message => {
  return Message({
    message: message,
    type: 'success',
    center: true,
    duration: 2000
  })
}

/** 失败的消息提醒 **/
export const Error =  message => {
  return Message({
    message: message,
    type: 'error',
    center: true,
    duration: 2000
  })
}

/** 普通消息提醒 **/
export const Info =  message => {
  return Message({
    message: message,
    type: 'info',
    center: true,
    duration: 2000
  })
}

/** 警告消息题型 **/
export const Warning = message => {
  return Message({
    message: message,
    type: 'warning',
    center: true,
    duration: 2000
  })
}

/** 警告选择框 **/
export const Confirm = (message, title) => {
  return MessageBox.confirm(message, title, {
    type: 'warning',
    confirmButtonText: '确定',
    cancelButtonText: '取消'
  })
}

/** 消息提示 **/
export const Alert = (message, title = "消息提醒") => {
  return MessageBox.alert(message, title, {
    confirmButtonText: '确定',
    // callback: action => { // 回调函数, 可以弹出消息提醒
    //   this.$message({
    //     type: 'info',
    //     message: `action: ${ action }`
    //   });
    // }
  })
}

/** 请求加载动画 **/
export const Load = () => {
  return Loading.service({
    lock: true,
    text: 'Loading',
    spinner: 'el-icon-loading',
    background: 'rgba(0, 0, 0, 0.7)'
  })
}
